class Solution {
    //不同路径
    public int uniquePaths(int m, int n) {
      //创建dp表
      int[][] dp = new int[m+1][n+1];
      //初始化
      dp[0][1] = 1;
      //填表
      for(int i = 1; i <= m; i++){
        for(int j = 1; j <= n; j++){
            dp[i][j] = dp[i-1][j] + dp[i][j-1];
        }
      }
      //返回
      return dp[m][n];
    }
    //不同路径II
    public int uniquePathsWithObstacles(int[][] obstacleGrid) {
        //创建dp表
        int m = obstacleGrid.length;
        int n = obstacleGrid[0].length;
        int[][] dp = new int[m+1][n+1];
        //初始化
        dp[0][1] = 1;
        //填表
        for(int i = 1; i <= m; i++){
            for(int j = 1; j <= n; j++){
                if(obstacleGrid[i-1][j-1] == 1) dp[i][j] = 0;
                else dp[i][j] = dp[i-1][j] + dp[i][j-1];
            }
        }
        //返回
        return dp[m][n];
    }
    //珠宝的最高价值
    public int jewelleryValue(int[][] frame) {
        //创建dp表
        int m = frame.length;
        int n = frame[0].length;
        int[][] dp = new int[m+1][n+1];
        //初始化
        //填表
        for(int i = 1; i <= m; i++){
            for(int j = 1; j <= n; j++){
                dp[i][j] = Math.max(dp[i-1][j], dp[i][j-1]) + frame[i-1][j-1];
            }
        }
        //返回
        return dp[m][n];

    }
}